#include <stdio.h>
#include <math.h>
#include <string.h>

int main(int argc, char const *argv[])
{
/*
    int i = 10;
    int *ipointer = &i;
    //ipointer = &i = &(*ipointer)
    //i = *ipointer = *(&i)
    printf("ipointer    =%p\n",ipointer);
    printf("&i          =%p\n",&i);
    printf("&(*ipointer)=%p\n",&(*ipointer));


    char   a = 10;
    short  b = 10;
    int    c = 10;
    long   d = 10;
    float  e = 10.1;
    double f = 10.1;

    printf("&a=%p\n",&a);
    printf("&b=%p\n",&b);
    printf("&c=%p\n",&c);
    printf("&d=%p\n",&d);
    printf("&e=%p\n",&e);
    printf("&f=%p\n",&f);

    char str[10]={0};
    for (int i = 0; i < 10; i++)
    {
        printf("&str[%d]=%p\n",i,&str[i]);
    }
 

    int x=10,y=10;
    int *pa,*pb;

    pa=&x;
    pb=&y;
  //输出x，y的值
    printf("x=%d\n",x);
    printf("y=%d\n",y);
    printf("\n");

  //直接访问   输出x，y的地址，pa，pb的地址
    printf("&x=%p\n",&x);
    printf("&y=%p\n",&y);
    printf("pa=%p\n",pa);
    printf("pb=%p\n",pb);
    printf("\n");

  //间接访问  输出pa, pb的值  pa，pb的地址
    printf("*pa=%d\n",*pa);
    printf("*pb=%d\n",*pb);
    printf("&pa=%p\n",&pa);
    printf("&pb=%p\n",&pb);
    printf("\n");


    char        a = 10;
    short       b = 10;
    int         c = 10;
    long        d = 10;
    long int    e = 10;
    long long   f = 10;
    float       g = 10.1;
    double      h = 10.1;
    long double i = 10.1;

    char        *pa = &a;
    short       *pb = &b;
    int         *pc = &c;
    long        *pd = &d;
    long int    *pe = &e;
    long long   *pf = &f;
    float       *pg= &g;
    double      *ph = &h;
    long double *pi = &i;

    printf("&a=%p\n",&a);
    printf("&b=%p\n",&b);
    printf("&c=%p\n",&c);
    printf("&d=%p\n",&d);
    printf("&e=%p\n",&e);
    printf("&f=%p\n",&f);
    printf("&g=%p\n",&g);
    printf("&h=%p\n",&h);
    printf("&i=%p\n",&i);


    printf("sizeof(char         )=%d\n",sizeof(char));
    printf("sizeof(char *       )=%d\n",sizeof(char *));
    printf("sizeof(pa           )=%d\n",sizeof(pa));

    printf("sizeof(short        )=%d\n",sizeof(short));
    printf("sizeof(short *      )=%d\n",sizeof(short *));
    printf("sizeof(pb           )=%d\n",sizeof(pb));

    printf("sizeof(int          )=%d\n",sizeof(int));
    printf("sizeof(int *        )=%d\n",sizeof(int *));
    printf("sizeof(pc           )=%d\n",sizeof(pc));

    printf("sizeof(long         )=%d\n",sizeof(long));
    printf("sizeof(long *       )=%d\n",sizeof(long *));
    printf("sizeof(pd           )=%d\n",sizeof(pd));

    printf("sizeof(long int     )=%d\n",sizeof(long int));
    printf("sizeof(long int *   )=%d\n",sizeof(long int *));
    printf("sizeof(pe           )=%d\n",sizeof(pe));

    printf("sizeof(long long    )=%d\n",sizeof(long long));
    printf("sizeof(long long *  )=%d\n",sizeof(long long *));
    printf("sizeof(pf           )=%d\n",sizeof(pf));

    printf("sizeof(float        )=%d\n",sizeof(float));
    printf("sizeof(float *      )=%d\n",sizeof(float *));
    printf("sizeof(pg           )=%d\n",sizeof(pg));

    printf("sizeof(double       )=%d\n",sizeof(double));
    printf("sizeof(double *     )=%d\n",sizeof(double *));
    printf("sizeof(ph           )=%d\n",sizeof(ph));

    printf("sizeof(long double  )=%d\n",sizeof(long double));
    printf("sizeof(long double *)=%d\n",sizeof(long double *));
    printf("sizeof(pi           )=%d\n",sizeof(pi));

    printf("pa=%p\n",pa);
    pa++;
    printf("pa=%p\n",pa);

    printf("pb=%p\n",pb);
    pb++;
    printf("pb=%p\n",pb);

    printf("pc=%p\n",pc);
    pc++;
    printf("pc=%p\n",pc);

    printf("pd=%p\n",pd);
    pd++;
    printf("pd=%p\n",pd);

    printf("pe=%p\n",pe);
    pe++;
    printf("pe=%p\n",pe);

    printf("pf=%p\n",pf);
    pf++;
    printf("pf=%p\n",pf);

    printf("pg=%p\n",pg);
    pg++;
    printf("pg=%p\n",pg);

    printf("ph=%p\n",ph);
    ph++;
    printf("ph=%p\n",ph);

    printf("pi=%p\n",pi);
    pi++;
    printf("pi=%p\n",pi);


    int a[5];
    int *pa=&a[0];
    int *pb=&a[3];
    printf("pa=%p\n",pa);
    printf("pb=%p\n",pb);
    printf("pb-pa=%d\n",pb-pa);


    int a[5] = {1,2,3,4,5};

    printf("&a[0]=%p\n",&a[0]);
    printf("&a[1]=%p\n",&a[1]);
    printf("&a[2]=%p\n",&a[2]);
    printf("&a[3]=%p\n",&a[3]);
    printf("&a[4]=%p\n",&a[4]);

    printf("a    =%p\n",a);
    printf("&a[0]=%p\n",&a[0]);


    int a,b;
    printf("请输入两个整数>:");
    scanf("%d%d",&a,&b);
    printf("a=%d,b=%d\n",a,b);

    int *pa=&a,*pb=&b;
    int min = (*pa<*pb)?*pa:*pb;
    printf("min=%d\n",min);


    double a[10]={1,2,3,4,5,6,7,8,9,10},*p = a;

    for (int i = 0; i < 10; i++)
    {
      printf("&a[%d]=%p\n",i,&a[i]);
      printf("a+%d =%p\n",i,a+i);
      printf("-----------------------\n");
    }
    
    for (int i = 0; i < 10; i++)
    {
      printf("*&a[%d]=%f\n",i,a[i]);
      printf("a[%d]  =%f\n",i,a[i]);
      printf("*(a+%d)=%f\n",i,*(a+i));
      printf("-----------------------\n");
    }
  

    int a[10]={1,2,3,4,5,6,7,8,9,10},*p = a;
    printf("第一种(a[i]数组下标法): \n");
    for (int i = 0; i < 10; i++)
    {
      printf("a[%d]=%d\n",i,a[i]);
    }

    printf("第二种(p[i]数组下标法): \n");
    for (int i = 0; i < 10; i++)
    {
      printf("p[%d]=%d\n",i,p[i]);
    }

    printf("第三种(*(a+i)指针法): \n");
    for (int i = 0; i < 10; i++)
    {
      printf("*(a+i)=%d\n",i,*(a+i));
    }

    printf("第四种(*(p+i)指针法): \n");
    for (int i = 0; i < 10; i++)
    {
      printf("*(p+i)=%d\n",i,*(p+i));
    }
*/

    int a[3][4];

    printf("a     =%p\n",a);
    printf("a[0]  =%p\n",a[0]);
    printf("*(a+0)=%p\n",*(a+0));
    printf("------------------------------\n");
    printf("a[1]  =%p\n",a[1]);
    printf("*(a+1)=%p\n",*(a+1));
    printf("------------------------------\n");
    printf("a[2]  =%p\n",a[2]);
    printf("*(a+2)=%p\n",*(a+2));
    printf("------------------------------\n");
    printf("&a[0][0]=%p\n",&a[0][0]);
    printf("a       =%p\n",a);
    printf("a[0]    =%p\n",a[0]);
    printf("------------------------------\n");
    
    printf("第一种：\n");
    for (int i = 0; i < 3; i++)
    {
      for (int j = 0; j < 4; j++)
      {
        printf("&a[%d][%d]=%p\n",i,j,&a[i][j]);
      }
      
    }
    printf("------------------------------\n");
    printf("第二种：\n");
    for (int i = 0; i < 3; i++)
    {
      for (int j = 0; j < 4; j++)
      {
        printf("*(*(a+%d)+%d)=%p\n",i,j,*(a+i)+j);
      }
      
    }



    return 0;
  }
